﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{$infoConfig.site_title}</title>
    <meta name="keywords" content="FAKE Framework"/>
    <meta name="description" content="FAKE is a lightweight php framework."/>
    <meta name="author" content="tianji">
    <meta name="renderer" content="webkit">
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <!-- icon -->
    <link rel="icon" type="image/x-icon" href="/static/icon.png">
    <!-- css -->
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/admin/font/iconfont.css?v=1.0.0" type="text/css" media="all">
    <link rel="stylesheet" href="/static/admin/css/adaption.css" type="text/css">
    <style>
        .kzt {
            height: 50px;
            line-height: 50px;
            background: #2B2E37;
            text-indent: 10px;
        }

        .kzt a {
            color: #FFF;
            margin-left: 9px;
        }

        .admin-iframe {
            width: 100%;
            border: 0;
            height: 100%;
        }

        #frameTab {
            padding-left: 10px;
        }

        #frameTab .layui-this {
            background: #1FA094;
            background: linear-gradient(#1FA094, #009688);
            color: #FFF;
        }
    </style>
</head>

<body class="layui-layout-body" data-version="{$infoConfig.switchVersion}">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">{$infoConfig.site_title}</div>
        <ul class="layui-nav layui-layout-left" id="menu" lay-filter="main-menu">
            {volist name="list" id="vo"}
            <li class="layui-nav-item {if $key==0}layui-this{/if}">
                <a href="javascript:;"><span>{$vo.name}</span></a>
            </li>
            {/volist}
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">前台引导</a>
                <dl class="layui-nav-child">
                    {volist name="listGuide" id="vo"}
                    <dd><a href="{$vo.url}" target="_blank">{$vo.name}</a></dd>
                    {/volist}
                </dl>
            </li>
            <li class="layui-nav-item" style="margin-right: 10px;">
                <a href="javascript:;">
                    <img src="/static/admin/images/header.jpg" class="layui-nav-img">
                    {if $loginUserInfo.nickname!=''}{$loginUserInfo.nickname}{else/}{$loginUserInfo.username}{/if}
                </a>
                <dl class="layui-nav-child">
                    <!--<dd><a href='{:url("login/outLogin")}'>安全退出</a></dd>-->
                    <dd><a href="javascript:;" class='layui-submit' data-type="out" data-name='清理缓存' data-url='{:url("login/outLogin")}'>安全退出</a></dd>
                    <dd><a href="javascript:;" class='layui-submit' data-type="clear" data-name='清理缓存' data-url='{:url("index/delCache")}'>清理缓存</a></dd>
                    <dd><a href="javascript:;" class='layui-submit' data-type="switch" data-name='切换 {$infoConfig.systemTitle}' data-url='{:url("index/switchVersion")}'>{$infoConfig.systemTitle}</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item">
                <button title="刷新" class="layui-btn layui-btn-normal layui-refresh"><i class="layui-icon">&#xe669;</i></button>
            </li>
        </ul>
    </div>
    <!-- /头部结束 -->

    <!-- 左侧导航(垂直导航) -->
    <div id="left-nav" class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!--子菜单项-->
            <p class='kzt' fold='1'>
                <a href="javascript:;" class='left-menu' data-title="控制台">
                    <i class="layui-icon">&#xe665;</i>
                    <span>控制台</span>
                </a>
            </p>
            <div id="submenu">
                {volist name="listSub" id="vo"}
                <div class="sub-menu" {if $key>0}style="display:none"{/if} >
                    <ul class="layui-nav layui-nav-tree">
                        {volist name="vo['list_sub']" id="sub"}
                        {if !empty($sub['sub_voo'])}
                        <li class="layui-nav-item layui-nav-itemed" data-bind="0">
                            <a href="javascript:;" data-title="{$sub.name}">
                                <span>{$sub.name}</span>
                                <em class="layui-nav-more"></em>
                            </a>
                            <dl class="layui-nav-child">
                                {volist name="sub['sub_voo']" id="voo"}
                                <dd class="dataurl">
                                    <a href="javascript:;" data-url="{:url($voo.url)}" data-title="{$voo.name}" data-id="{$voo.id}">
                                        <span>{$voo.name}</span>
                                    </a>
                                </dd>
                                {/volist}
                            </dl>
                        </li>
                        {else/}
                        <li class="layui-nav-item dataurl">
                            <a href="javascript:;" data-url="{:url($sub.url)}" data-title="{$sub.name}" data-id="{$sub.id}">
                                <span>{$sub.name}</span>
                            </a>
                        </li>
                        {/if}
                        {/volist}
                    </ul>
                </div>
                {/volist}
            </div>
        </div>
    </div>
    <!-- /左侧侧边导航结束 -->

    <!-- 右侧主体内容 -->
    <div class="layui-body">
        <div class="layui-tab layui-tab-card" id="admin-tab" lay-filter="adminTab" lay-allowclose="true">
            <ul id="frameTab" class="layui-tab-title" {if $infoConfig.switchVersion== 1}style='display:none;' {
            /if} >
            <li class="layui-this"><em>管理首页</em></li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show" id="right-content">
                    <iframe class="admin-iframe" name="mhsh_iframe" id="mhsh_iframe" data-id='0' src="{:url('home/main')}"></iframe>
                </div>
            </div>
        </div>
    </div>
    <!-- 底部区域 -->
    <div class="layui-footer">
        <div class="layui-mian">
            <span class="layui">2018 &copy;</span>
            <span class="layui">{$infoConfig.site_copyright}</span>
        </div>
    </div>
</div>
</body>
<!-- / -->
<script src="/static/layui/layui.js"></script>
<script>
    var tabAryId = ['7'];	//框架版选项卡存储页面id全局数组
    layui.config({
        base: '/static/admin/js/',
        version: true,
    }).use('tabmenu');
    layui.use(['jquery', 'element', 'layer'], function () {
        var $ = layui.jquery
            , element = layui.element
            , layer = layui.layer;

        //<!-- /头部区域(水平导航) 点击监听 -->
        $('#menu .layui-nav-item').on('click', function () {
            var num = $(this).index();
            console.log('top-nav', num);

            //顶部主菜单
            $('#menu .layui-nav-item').removeClass('layui-this');
            $('#menu .layui-nav-item:eq(' + num + ')').addClass('layui-this');

            //左侧子菜单
            $('.sub-menu').css('display', 'none');
            $('.sub-menu:eq(' + num + ')').css('display', 'block');
            $('#submenu .layui-nav-item').removeClass('layui-this');
        });

        //左侧菜单监听
        $('#submenu .dataurl').on('click', function () {
            var datatitle = $(this).children('a').attr('data-title');
            var dataurl = $(this).children('a').attr('data-url');
            var id = $(this).children('a').attr('data-id');
            //console.log('lef-nav',datatitle,dataurl,id);

            //框架版本：1单页/2框架
            var version = $('.layui-layout-body').attr('data-version');
            if (version == 1) {
                //单页版
                $("#frameTab").css('display', 'none');
                $("#mhsh_iframe").attr("src", dataurl);
            } else {
                if ($.inArray(id, tabAryId) == '-1') {
                    //不存在id 创建选项卡
                    element.tabAdd('adminTab', {
                        title: datatitle
                        , content: '<iframe class="admin-iframe" name="mhsh_iframe" src="' + dataurl + '"></iframe>'
                        , id: id
                    });
                    tabAryId.push(id);
                }
                element.tabChange('adminTab', id);	//切换选项卡

                var styleiframe = $(".layui-body").height() - 100;
                $("#admin-tab .layui-show").css('height', styleiframe + 'px');
            }
        });
        element.on('tabDelete(adminTab)', function (data) {
            tabAryId.splice(data.index, 1);
        });
        element.render();

        //通用按钮监听事件
        $('.layui-submit').on('click', function () {
            var type = $(this).attr('data-type');	//必填 del add edit clear
            var url = $(this).attr('data-url');		//必填
            var name = $(this).attr('data-name');	//必填
            var field = $(this).attr('data-field');
            var value = $(this).attr('data-value');

            if (typeof (type) != 'undefined') {
                layer.open({
                    type: 1
                    , title: '提示'
                    , content: '<div style="padding:20px 100px;">确认 ' + name + ' 操作吗？</div>'
                    , btn: '确定'
                    , btnAlign: 'c' //按钮居中
                    , shade: 0 //不显示遮罩
                    , yes: function (index) {
                        if (typeof (field) != 'undefined') {
                            var data = {};
                            data[field] = value;
                        } else {
                            var data = {};
                            data['id'] = 1;
                        }
                        $.ajax({
                            url: url,
                            data: data,
                            type: "post",
                            dataType: 'json',
                            success: function (res) {
                                //数据处理
                                layer.close(index);
                                if (res.code == 1) {
                                    //返回OK 正常信息
                                    layer.msg(res.msg, {icon: 1, time: 1000}, function (index) {
                                        location.reload();
                                    });
                                }
                                if (res.code == 2) {
                                    //返回OK 临时性重定向
                                    layer.msg(res.msg, {icon: 1, time: 1000}, function (index) {
                                        window.location.href = res.data.url;
                                    });
                                }
                                if (res.code == 0) {
                                    //返回Error 返回错误
                                    layer.msg(res.msg, {icon: 2, time: 2000}, function (index) {

                                    });
                                }
                            }
                        });
                    }
                });
            }
        });

    });
</script>
</html>